<template>
  <div class="main">
    <div class="btn">
      <el-button
        v-show="newFn"
        @click="newForm"
        type="primary"
        icon="el-icon-circle-plus-outline"
        style="background:#ff6a27;border:#ff6a27"
      >新建</el-button>
    </div>
    <div class="table">
      <template>
        <el-table :data="list" style="width: 100%" v-loading="loading" ref="form">
          <el-table-column label="序号" type="index" width="160"></el-table-column>

          <el-table-column
            v-for="(item, index) in tabHeader"
            :key="item"
            :prop="index"
            :label="item"
            width="280"
          ></el-table-column>

          <el-table-column label="操作" prop="operation" width="160" v-if="operation">
            <template #default="{row}">
              <slot name="operation" :row="row"></slot>
            </template>
          </el-table-column>
        </el-table>
      </template>
    </div>
  </div>
</template>

<script>
export default {
  name: 'DikedIndex',
  props: {
    tabHeader: {
      type: Object,
      default: () => ({})
    },
    list: {
      type: Array,
      default: () => []
    },
    loading: {
      type: Boolean,
      default: false
    },
    newFn: {
      type: Boolean,
      default: false
    },
    operation: {
      type: Boolean,
      default: true
    }
  },
  data () {
    return {}
  },
  created () {},
  mounted () {},
  methods: {
    // 添加
    newForm () {
      this.$emit('newForm', true)
    }
  }
}
</script>

<style lang="less" scoped>
.main {
  margin-top: 20px;
  padding: 20px;
  background-color: #fff;
  .btn {
    text-align: left;
  }
}
</style>
